package config

import (
	"github.com/spf13/viper"
	"log"
)

type Mysql struct {
	User     string
	Password string
	Host     string
	Port     int
	Database string
}
type Redis struct {
	Addr     string
	Password string
	DB       int
}
type ApiConfig struct {
	Mysql
	Redis
}

var AppViperData ApiConfig

func GetViperData() {
	v := viper.New()
	v.SetConfigFile("./dev.yaml")
	err := v.ReadInConfig()
	if err != nil {
		return
	}
	err = v.Unmarshal(&AppViperData)
	if err != nil {
		panic(err)
	} else {
		log.Println("viper init success")
	}
}
